<%@ page import="java.util.List" %>
<%@ page import="entity.Man" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/9/19
  Time: 19:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>



<html>
<head>
    <title>Title</title>
  <style>
    table,th,td{
      border: 1px solid black;
      border-collapse: collapse;
      padding: 5px;
    }
  </style>
</head>
<body>
<input type="button" id="btn"  name="btn" value="查询">
<table width="100%" border="1px" id="zhu">
  <tr>
    <td>编号</td>
    <td>姓名</td>
    <td>年龄</td>
    <td>地址</td>
  </tr>
<tr>
  <th>ID</th>
  <th>姓名</th>
  <th>性别</th>
  <th>操作</th>
</tr>
</table>

<h2> 新增学生</h2>
<div>
  <form action="/Studentservlet?opr=addStudent" method="post">
    <table>
    <tr>
      <td>姓名</td>
      <td><input type="text" name="name"></td>
    </tr>
      <tr>
        <td>年龄</td>
        <td><input type="text" name="age"></td>
      </tr>
      <tr>
        <td>地址</td>
        <td><input type="text" name="mojor"></td>
      </tr>

      <tr>
        <td colspan="2">
          <input type="submit" value="提交" id="addIsSuccess">
          <input type="reset" value="清空">
        </td>
      </tr>
    </table>
  </form>
</div>
<h2>学生修改</h2>
<div id="update">
  <form action = "/Studentservlet?opr=updateStudent" method="post">
  <table>
    <tr>
      <td>id</td>
      <td><input type="text" name="upid"></td>
    </tr>
    <tr>
      <td>姓名</td>
      <td><input type="text" name="upname"></td>
    </tr>
    <tr>
      <td>age</td>
      <td><input type="text" name="upage"></td>
    </tr>
    <tr>
      <td>地址</td>
      <td><input type="text" name="upmojor"></td>
    </tr>
    <td colspan="2">
      <input type="submit" value="提交" id="updateIsSuccess">
      <input type="reset" value="清空">
    </td>
  </table>
  </form>
</div>
<br>
<h2>学生开除</h2>
<div id="delete">
  <form action = "/Studentservlet?opr=deleteStudent" method="post">
    <table>
      <tr>
        <td>id</td>
        <td><input type="text" name="did"></td>
      </tr>
      <input type="submit" value="提交" id="deleteIsSuccess">
      <input type="reset" value="清空">
    </table>
  </form>
</div>
<script type="text/javascript" src="js/jquery.js"></script>
<script>
  $("#btn").click(function (){
    $.ajax({

      "url" : "/Studentservlet",
      "type" : "post",
      "dataType" : "json",
      "success" : function (data){
        console.log(data);
        for (var i = 0; i < data.length; i++) {
          var $tr =("<tr><td>"+data[i].id+"</td><td>"+data[i].name+"</td><td>"+data[i].age+"</td><td>"+data[i].mojor+"</td></tr>");
          $("#zhu").append($tr)
        }
      }
    })
  })
  // $("#btn").click(function (){
  //   $.ajax({
  //     "url" : "/Studentservlet",
  //     "type" : "post",
  //     "dataType" : "json",
  //     "success" : function (data){
  //       console.log(data);
  //       for (var i = 0; i < data.length; i++) {
  //         var $tr =("<tr><td>"+data[i].id+"</td><td>"+data[i].name+"</td><td>"+data[i].age+"</td><td>"+data[i].mojor+"</td></tr>");
  //         $("#zhu").append($tr)
  //       }
  //     }
  //   })
  // })
</script>

</body>
</html>
